﻿Public Class UC_Quanlyhanghoa
    dim m As New DTOMonAn
    Sub loadnhomhang()
        cbbNhomHang.DataSource = DataProvider.LoadTable("select * from NHOMHANG")
        cbbNhomHang.ValueMember = "MaHang"
        cbbNhomHang.DisplayMember = "TenHang"
        cbbNhomHang.SelectedIndex = 1
    End Sub
    Sub LoadMonan()
        gvMonAn.DataSource = BUSMonAn.MonAn_Load
    End Sub
    Sub sendData()
        m.MaMA = gvMonAn.CurrentRow.Cells("MAMA").Value
        m.TenMA = gvMonAn.CurrentRow.Cells("tenMA").Value
        m.DonGia = gvMonAn.CurrentRow.Cells("Dongia").Value
        m.MaHang = gvMonAn.CurrentRow.Cells("MaHang").Value
        Dim f As New F_MonAn
        f.receiveData(m, 0)
        f.ShowDialog()
    End Sub
    Private Sub UC_Quanlyhanghoa_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        loadnhomhang()
        LoadMonan
    End Sub

    Private Sub binsert_Click(sender As Object, e As EventArgs) Handles binsert.Click
        Dim f As New F_MonAn
        f.ShowDialog
        LoadMonan()
    End Sub

    Private Sub bedit_Click(sender As Object, e As EventArgs) Handles bedit.Click
       sendData
        LoadMonan()
    End Sub

    Private Sub ddelete_Click(sender As Object, e As EventArgs) Handles ddelete.Click
        m.MaMA = gvMonAn.CurrentRow.Cells("MAMA").Value
        BUSMonAn.MonAn_Delete(m)
        loadnhomhang()
        LoadMonan
    End Sub
End Class
